package com.cetc.nsfx.impala;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public class ImpalaDataResult {
	/**
	 * 根据SQL查询并返回List
	 * @param sql
	 * @return
	 * @throws Exception
	 */
	public static List<Map<String,Object>> executeSQL(String sql) {
		Connection conn = ImpalaJDBCUtil.getImpalaConnection();
		PreparedStatement ps= null;
        ResultSet rs=null;
        List<Map<String,Object>> list=null;
        try {
			ps = conn.prepareStatement(sql);
			rs=ps.executeQuery();
		    list=ImpalaJDBCUtil.convertList(rs);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			ImpalaJDBCUtil.close(conn,null,ps,rs);
		}
		return list;
	}
}
